<template>
  <div class="pages_content table">
    <el-container>
      <el-header>
        <breaDcrumb />
      </el-header>

      <el-main>
        <!-- 导航 -->
        <div class="tabtop">
          <div v-for="(item, index) in navlist" :key="index" @click="choose(item.id)">
            <div :class="currenindex == index + 1 ? 'active' : 'text'">{{ item.value }}</div>
            <div v-if="currenindex !== index + 1 && currenindex !== index + 2 && index !== 2" class="hr"></div>
          </div>
        </div>
        <!-- 搜索条件 -->
        <div v-loading="pagesLoading">
          <!-- 折叠 -->
          <div class="header_right" @click="showCardNav = !showCardNav">
            <div class="title">搜索</div>
            <div>
              <transition name="from"></transition>
              <span v-show="!showCardNav">
                <i style="margin-right: 5px" class="el-icon-arrow-down"></i>
              </span>
              <transition name="to"></transition>
              <span v-show="showCardNav">
                <i style="margin-right: 5px" class="el-icon-arrow-up"></i>
              </span>
            </div>
          </div>
          <div v-show="showCardNav" class="hr"></div>
          <!-- 搜索内容 -->
          <el-collapse-transition>
            <div v-show="showCardNav" style="padding-top:18px">
              <el-form :inline="true" label-width="110px">
                <!-- 搜索条件1 -->
                <el-form-item v-if="currenindex==1" label-width="160px">
                  <span slot="label">混凝土运输供应商</span>
                  <div style="width:240px;height:36px;display:flex;">
                    <div :title="searchText" style="width:180px;padding:0 10px;border-bottom: 1px solid #bbb;margin-right:5px;" class="ellipsis">{{searchText}}</div>
                    <el-button class="bottom_all_two" @click="getsearchData(),search=true">选择</el-button>
                  </div>
                </el-form-item>
                <el-form-item v-if="currenindex==1" label-width="160px">
                  <span slot="label">生产站点</span>
                  <el-select v-model="productionSiteId" placeholder="请选择" multiple>
                    <el-option v-for="(item,index) in stationsList" :key="index" :label="item.name" :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item v-if="currenindex==1">
                  <span slot="label">结算时间段</span>
                  <el-date-picker v-model="datePicker" style="height:36px" type="datetimerange" unlink-panels align="right" start-placeholder="开始时间" end-placeholder="结束时间" :default-time="['12:00:00', '08:00:00']" value-format="yyyy-MM-dd HH:mm:ss">
                  </el-date-picker>
                </el-form-item>
                <!-- 搜索条件2 -->
                <el-form-item v-if="currenindex==2">
                  <span slot="label">运输单位</span>
                  <el-select v-model="tableParam.supplierId" placeholder="请选择">
                    <el-option v-for="(item,index) in searchData" :key="index" :label="item.supplierName" :value="item.supplierId"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item v-if="currenindex==2">
                  <span slot="label">生产站点</span>
                  <el-select v-model="productionSiteId" multiple placeholder="请选择">
                    <el-option v-for="(item,index) in stationsList" :key="index" :label="item.name" :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item v-if="currenindex==2">
                  <span slot="label">送达时间</span>
                  <el-date-picker v-model="datePicker" style="height:36px" type="datetimerange" unlink-panels align="right" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['12:00:00', '08:00:00']" value-format="yyyy-MM-dd HH:mm:ss">
                  </el-date-picker>
                </el-form-item>
                <!-- 搜索条件3 -->
                <el-form-item v-if="currenindex==3">
                  <span slot="label">结算单号</span>
                  <el-input v-model="tableParam.statementNo" placeholder="请输入" clearable></el-input>
                </el-form-item>
                <el-form-item v-if="currenindex==3">
                  <span slot="label">运输供应商</span>
                  <el-select v-model="tableParam.supplierId" placeholder="请选择">
                    <el-option v-for="(item,index) in searchData" :key="index" :label="item.supplierName" :value="item.supplierId"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item v-if="currenindex==3">
                  <span slot="label">提交时间</span>
                  <el-date-picker v-model="datePicker" style="height:36px" type="datetimerange" unlink-panels align="right" start-placeholder="开始时间" end-placeholder="结束时间" :default-time="['12:00:00', '08:00:00']" value-format="yyyy-MM-dd HH:mm:ss">
                  </el-date-picker>
                </el-form-item>
                <el-form-item>
                  <el-button icon="el-icon-search" size="medium" class="bottom_all" @click="(tableParam.page = 1), pagesgettableData()">查 询</el-button>
                  <el-button v-if="currenindex!=1" size="medium" class="bottom_all_two" style="margin-left: 12px" @click="init()">重 置</el-button>
                </el-form-item>
              </el-form>
            </div>
          </el-collapse-transition>
          <div class="hr"></div>
          <!-- 页面内容区 -->
          <div class="card" :style="currenindex!==1?'padding-top:10px':''">
            <!-- 页面功能按钮区 -->
            <div v-show="currenindex==1" class=" card_nav">
              <div>
                <el-button v-if="ButtonList.findIndex(res=>(res.buttonValue=='SHENGCJSD'))!==-1" size="small" class="bottom_three" :disabled="generate.logisticsList.length==0" @click="statements()">
                  生成结算单
                </el-button>
              </div>
              <div>
              </div>
            </div>
            <!-- 表格数据 -->
            <div v-loading="tableLoading" class="card_info" :style="style">
              <el-table ref="table" :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="tableData" tooltip-effect="dark" @selection-change="tableChange">
                <el-table-column v-if="currenindex==1" align="center" type="selection"></el-table-column>
                <template v-for="(item, index2) in table">
                  <el-table-column v-if="item.status" :key="index2" :label="item.label" align="center" :min-width="item.width" :fixed="item.label =='操作'?'right':false">
                    <template slot-scope="scope">
                      <span v-if="item.label == '浇筑方式'">
                        <div v-for="(item1,index1) in scope.row.pouringMethodList" :key="index1">
                          {{item1[item.prop]}}
                        </div>
                      </span>
                      <div v-else-if="item.label == '结算单号'" class="table_link" @click="show( scope.row)">
                        {{ scope.row[item.prop] }}
                      </div>
                      <span v-else-if="item.label == '序号'">
                        {{scope.$index+1}}
                      </span>
                      <span v-else-if="item.label == '结算时间段'">
                        {{scope.row.startTime}}-{{scope.row.endTime}}
                      </span>
                      <span v-else-if="item.label == '内部审核状态'">
                        {{scope.row.auditStatus==0?'审核中':scope.row.auditStatus==1?'通过':scope.row.auditStatus==2?'不通过':'待提交审核'}}
                      </span>
                      <span v-else-if="item.label == '操作'">
                        <!-- <span v-if="scope.row.auditStatus==1" class="table_link" @click="send(scope.row)">
                          发送
                        </span> -->

                        <el-button v-if="scope.row.auditStatus==1" size="mini" class="bottom_all_two" @click="userSubmit(scope.row)">
                          发送
                        </el-button>
                        <el-button v-if="billDetails1.auditStatus==3" size="mini" class="bottom_all_two" @click="$router.push({ name: 'sign_Wise_rentunit2', query: { id: scope.row.statementNo, type: 1 } })">提交审核</el-button>
                      </span>
                      <span v-else-if="item.label == '供应商确认'">
                        {{scope.row.supplierConfirm==1?'待查看':scope.row.supplierConfirm==2?'已同意':'未发送'}}
                      </span>
                      <span v-else>{{ scope.row[item.prop] }}</span>
                    </template>
                  </el-table-column>
                </template>
              </el-table>
            </div>
            <!-- 翻页 -->
            <!-- <div class="card_bottom">
              <div class="card_bottom_left">
                <div class="top_page_totle">总共{{ total }}条</div>
                <el-pagination :current-page.sync="tableParam.page" :page-size="tableParam.pageSize" layout="prev, pager, next, jumper" :total="total" @current-change="pagesgettableData()"></el-pagination>
              </div>
              <div>
                <el-button size="mini" icon="el-icon-refresh-right" class="bottom_all_two" @click="pagesgettableData()">刷新</el-button>
              </div>
            </div> -->
          </div>
        </div>
      </el-main>
      <div class="card_bottom">
        <div class="card_bottom_left">
          <div class="top_page_totle">总共{{ total }}条</div>
          <el-pagination :current-page.sync="tableParam.page" :page-size="tableParam.pageSize" layout="prev, pager, next, jumper" :total="total" @current-change="pagesgettableData()"></el-pagination>
        </div>
        <div>
          <el-button size="mini" icon="el-icon-refresh-right" class="bottom_all_two" @click="pagesgettableData()">刷新</el-button>
        </div>
      </div>
    </el-container>
    <!-- 选择供应商合同 -->
    <el-dialog v-dialogDrag :visible.sync="search" width="680px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">选择混凝土料运输供应商</span>
      <div class="dialoginfo">
        <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="searchData" tooltip-effect="dark" @row-click='setradio'>
          <el-table-column align="center" label="选择">
            <template slot-scope="scope">
              <el-radio :value="searchradio" :label="JSON.stringify(scope.row)">{{''}}</el-radio>
            </template>
          </el-table-column>
          <el-table-column align="center" label="合同编号" prop="contractNumber"></el-table-column>
          <el-table-column align="center" label="合同单位" prop="supplierName"></el-table-column>
          <!-- <el-table-column align="center" label="合作等级" prop="gradeName"></el-table-column> -->
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="search=false">取 消</el-button>
        <el-button class="bottom_all" style="margin-left: 24px" @click="submitsearch">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 混凝土运输结算单 -->
    <el-dialog v-dialogDrag :visible.sync="billDeta" width="1180px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">混凝土运输结算单</span>
      <div ref="html" style="padding:10px 20px">
        <div class="bill_top">
          <span><span class="text">运输供单位：</span>{{billDetails.concreteStatement.supplier}}</span>
          <span><span class="text">结算时间段：</span>{{billDetails.concreteStatement.startTime}}至{{billDetails.concreteStatement.endTime}}</span>
          <span><span class="text">结算单编号：</span>{{billDetails.concreteStatement.statementNo}}</span>
          <!-- <span>
            <span class="text">考核得分：</span>
            <el-input type="Number" style="width:100px" v-model="billDetails.statementNo" placeholder="请输入" clearable></el-input>
          </span>
          <span><span class="text">结算油价：</span>
            <el-input type="Number" style="width:100px" v-model="billDetails.statementNo" placeholder="请输入" clearable></el-input>
          </span> -->
        </div>
        <div class="bill_title1">混凝土运载：</div>
        <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="billDetails.concreteDetails" tooltip-effect="dark">
          <el-table-column label="站点" align="center" prop="productionSite"></el-table-column>
          <el-table-column label="运输方量(方)" align="center" prop="faceValue"></el-table-column>
          <el-table-column label="运距区间（公里）" align="center" prop="distanceInterval"></el-table-column>
          <el-table-column label="基本单价(元/方)" align="center" prop="unitPrice"></el-table-column>
          <el-table-column label="结算单价(元/吨)" align="center" prop="">
            <template slot-scope="scope">
              <el-input v-model="scope.row.settleUnitPrice" type="Number" style="width:100%" placeholder="请输入" clearable></el-input>
            </template>
          </el-table-column>
          <el-table-column label="结算金额（元）" align="center">
            <template slot-scope="scope">
              {{scope.row.settleAmount=Number(scope.row.settleUnitPrice)*Number(scope.row.faceValue)}}
            </template>
          </el-table-column>
        </el-table>
        <div class="combined">合计：运输方量【{{combined(billDetails.concreteDetails)}}】，结算金额【{{combined1(billDetails.concreteDetails)}}】</div>
        <div class="bill_title">特殊运载：</div>
        <div style="padding-bottom:10px;">
          <el-button size="small" class="bottom_all" style="margin-left: 0" @click="additem()">
            <i class="icon iconfont iconicon_button_add" style="font-size: 12px"></i>
            添加
          </el-button>
        </div>

        <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="billDetails.concreteSpecialDetails" tooltip-effect="dark">
          <el-table-column label="运输物料名称" align="center" prop="">
            <template slot-scope="scope">
              <el-input v-model="scope.row.materielName" style="width:100%" placeholder="请输入" clearable></el-input>
            </template>
          </el-table-column>
          <el-table-column label="运输量" align="center" prop="">
            <template slot-scope="scope">
              <el-input v-model="scope.row.transportNum" type="Number" style="width:100%" placeholder="请输入" clearable></el-input>
            </template>
          </el-table-column>
          <el-table-column label="运距区间" align="center" prop="">
            <template slot-scope="scope">
              <el-input v-model="scope.row.distanceInterval" type="Number" style="width:100%" placeholder="请输入" clearable></el-input>
            </template>
          </el-table-column>
          <el-table-column label="单价(元)" align="center" prop="">
            <template slot-scope="scope">
              <el-input v-model="scope.row.unitPrice" type="Number" style="width:100%" placeholder="请输入" clearable></el-input>
            </template>
          </el-table-column>
          <el-table-column label="结算金额 (元)" align="center">
            <template slot-scope="scope">
              {{scope.row.settleAmount=Number(scope.row.transportNum)*Number(scope.row.unitPrice)}}
            </template>
          </el-table-column>
          <el-table-column label="操作" align="left">
            <template slot-scope="scope">
              <el-button size="mini" class="bottom_two" @click="delitem(scope.$index)">
                <i class="icon iconfont iconicon_button_delete" style="font-size: 12px"></i>
                删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="combined">合计：{{combined1( billDetails.concreteSpecialDetails)}}</div>
      </div>
      <span slot="footer" class="dialog-footer" style="display:flex;justify-content: space-between;">
        <div>
          <el-button class="bottom_all_two">打印结算单</el-button>
          <!-- <el-button class="bottom_all_two" @click="combinedSubmit(2)">提交审核</el-button> -->
        </div>
        <div>
          <el-button class="bottom_all_two" @click="billDeta=false">取 消</el-button>
          <el-button class="bottom_all" style="margin-left: 24px" @click="combinedSubmit(1)">保 存</el-button>
        </div>
      </span>
    </el-dialog>
    <!-- 查看混凝土运输结算单 -->
    <el-dialog v-dialogDrag :visible.sync="billDeta1" width="1180px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">混凝土运输结算单</span>
      <div>
        <div class="bill_title1">混凝土运载：</div>
        <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="billList1.concreteDetailList" tooltip-effect="dark">
          <el-table-column label="运输方量(方)" align="center" prop="faceValue"></el-table-column>
          <el-table-column label="运距区间（公里）" align="center" prop="distanceInterval"></el-table-column>
          <el-table-column label="基本单价(元/方)" align="center" prop="unitPrice"></el-table-column>
          <el-table-column label="结算单价(元/吨)" align="center" prop="settleUnitPrice">
          </el-table-column>
          <el-table-column label="结算金额（元）" align="center" prop="settleAmount">
          </el-table-column>
        </el-table>
        <div class="combined">合计：运输方量【{{combined(billList1.concreteDetailList)}}】，结算金额【{{combined1(billList1.concreteDetailList)}}】</div>
        <div v-if="billList1.concreteSpecialDetailList">
          <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="billList1.concreteSpecialDetailList" tooltip-effect="dark">
            <el-table-column label="运输物料名称" align="center" prop="materielName">
            </el-table-column>
            <el-table-column label="运输量" align="center" prop="transportNum">
            </el-table-column>
            <el-table-column label="运距区间" align="center" prop="distanceInterval">
            </el-table-column>
            <el-table-column label="单价(元)" align="center" prop="unitPrice">
            </el-table-column>
            <el-table-column label="结算金额 (元)" align="center" prop="settleAmount">
            </el-table-column>
          </el-table>
          <div class="combined">合计：{{combined1( billList1.concreteSpecialDetailList)}}</div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer" style="display:flex;justify-content: space-between;">
        <div>
          <el-button class="bottom_all_two">打印结算单</el-button>
          <el-button v-if="low.auditStatus==3" class="bottom_all_two" @click="combinedSubmit(3)">提交审核</el-button>
        </div>
        <div>
          <el-button class="bottom_all_two" @click="billDeta1=false">取 消</el-button>
        </div>
      </span>
    </el-dialog>
    <!--选择发送的人员-->
    <!-- <el-dialog v-dialogDrag :visible.sync="userDeta" width="620px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">请选择接收账号</span>
      <div style="padding:0 10px">
        <el-checkbox-group v-model="userarr">
          <template v-for="(item,index) in useroptons">
            <el-checkbox :key="index" style="line-height:26px" :label="item.id">{{item.name}}</el-checkbox>
          </template>
        </el-checkbox-group>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="userDeta=false">取 消</el-button>
        <el-button class="bottom_all" :disabled="userarr.length==0" style="margin-left: 24px" @click="userSubmit()">发 送</el-button>
      </span>
    </el-dialog> -->
  </div>
</template>

<script>
import mixin from "@/mixins/ICPSmixin.js";
import {
  QueryPage,
  queryPage1,
  generate_statement_detail,
  save_statement_detail,
  queryPage3,
  generate_statement,
  get_statement_detail_by_statement_no
  //getDetail
} from "@/api/wise/Wise_rentunit/Wise_rentunit2.js";
import html2canvas from 'html2canvas';
import {
  // queryUserByID,
  informClient
} from "@/api/wise/Wise_contactsbusiness/Wise_contactsbusiness.js";
import { getUserAutList } from '@/api/common.js'
export default {
  mixins: [mixin],
  data() {
    return {
      pagesLoading: false,
      /*表格增删改查及下载接口*/
      queryPage: '',
      /*表格数据*/
      table: [],
      table1: [
        { label: "运输单位", width: "auto", prop: "yunCompany", status: true },
        { label: "订单号", width: "auto", prop: "orderNo", status: true },
        { label: "运输号", width: "120", prop: "transportNo", status: true },
        { label: "车牌号", width: "auto", prop: "carNo", status: true },
        { label: "产品名称", width: "120", prop: "productName", status: true },
        { label: "工程名称", width: "auto", prop: "engineeringName", status: true },
        { label: "生产站点", width: "120", prop: "productionSite", status: true },
        { label: "理论装载量", width: "auto", prop: "maxLoad", status: true },
        { label: "运输方量(方)", width: "120", prop: "faceValue", status: true },
        { label: "运输距离(千米)", width: "120", prop: "transportDistance", status: true },
        { label: "运输单价(元/方)", width: "120", prop: "transportUnitPrice", status: true },
        { label: "运输费用（元）", width: "120", prop: "transportAmount", status: true },
        { label: "余料运输量(方)", width: "120", prop: "residueNum", status: true },
        { label: "余料运输距离(千米)", width: "120", prop: "residueDistance", status: true },
        { label: "余料运输单价(元/方)", width: "120", prop: "residueUnitPrice", status: true },
        { label: "余料运输费用(元)", width: "120", prop: "residueTransportAmount", status: true },
        { label: "结算金额（元）", width: "120", prop: "settlementAmount", status: true },
        { label: "送达时间", width: "120", prop: "affirmTime", status: true },
        { label: "浇筑方式", width: "120", prop: "pouringWay", status: true },
      ],
      table2: [
        { label: "运输单位", width: "auto", prop: "yunCompany", status: true },
        { label: "订单号", width: "auto", prop: "orderNo", status: true },
        { label: "运输号", width: "120", prop: "transportNo", status: true },
        { label: "车牌号", width: "auto", prop: "carNo", status: true },
        { label: "产品名称", width: "120", prop: "productName", status: true },
        { label: "工程名称", width: "auto", prop: "engineeringName", status: true },
        { label: "生产站点", width: "120", prop: "productionSite", status: true },
        { label: "理论装载量", width: "auto", prop: "maxLoad", status: true },
        { label: "运输方量(方)", width: "120", prop: "faceValue", status: true },
        { label: "运输距离(千米)", width: "120", prop: "transportDistance", status: true },
        { label: "运输单价(元/方)", width: "120", prop: "transportUnitPrice", status: true },
        { label: "运输费用（元）", width: "120", prop: "transportAmount", status: true },
        { label: "余料运输量(方)", width: "120", prop: "residueNum", status: true },
        { label: "余料运输距离(千米)", width: "120", prop: "residueDistance", status: true },
        { label: "余料运输单价(元/方)", width: "120", prop: "residueUnitPrice", status: true },
        { label: "余料运输费用(元)", width: "120", prop: "residueTransportAmount", status: true },
        { label: "结算金额（元）", width: "120", prop: "settlementAmount", status: true },
        { label: "送达时间", width: "120", prop: "affirmTime", status: true },
        { label: "浇筑方式", width: "120", prop: "pouringWay", status: true },
        { label: "结算单号", width: "120", prop: "statementNo", status: true },
      ],
      table3: [
        { label: "序号", width: "50", prop: "", status: true },
        { label: "结算单号", width: "310", prop: "statementNo", status: true },
        { label: "运输供应商", width: "140", prop: "supplier", status: true },
        { label: "结算时间段", width: "310", prop: "", status: true },
        { label: "结算总金额（元）", width: "160", prop: "statementAmount", status: true },
        { label: "提交时间", width: "160", prop: "createTime", status: true },
        { label: "内部审核状态", width: "120", prop: "", status: true },
        { label: "操作", width: "120", prop: "", status: true },
        { label: "供应商确认", width: "120", prop: "", status: true },
      ],
      pagesType: 0,
      /**导航栏*/
      navlist: [
        {
          value: "待结算",
          id: 1,
        },
        {
          value: "已结算",
          id: 2,
        },
        {
          value: "结算单",
          id: 3,
        },
      ],
      currenindex: 1,
      /**时间*/
      datePicker: [],
      /**搜索条件1*/
      searchText: '',
      search: false,
      searchData: [],
      searchradio: '',
      /**生成结算的数据*/
      generate: {
        logisticsList: [],
        clearingSourceId: '',
        startTime: '',
        endTime: '',
        contractId: ''
      },
      /*结算单详情*/
      billDeta: false,
      billDetails: {
        concreteStatement: {
          supplier: '',
          startTime: '',
          endTime: '',
          statementNo: ''
        },
        concreteDetails: [],
        concreteSpecialDetails: []
      },
      billList: [],
      totalList: [],
      stationsList: [],
      productionSiteId: [],
      /**查看结算单*/
      low: {},
      billList1: {
        concreteDetailList: [],
        concreteSpecialDetailList: [],
      },
      billDeta1: false,
      userDeta: false,
      useroptons: [],
      userarr: [],
    };
  },
  async created() {
    /*存储拷贝的原初始化fromDate数据*/
    this.stationsList = await getUserAutList(true)

  },
  watch: {
    /**导航切换*/
    currenindex: {
      handler() {
        this.tableData = []
        this.datePicker = []
        this.tableParam = this.$options.data().tableParam
        this.pagesLoading = true
        this.getsearchData()
        if (this.currenindex == 1) {
          this.searchText = ''
          this.table = this.table1;
          this.tableParam.examineStatus = 0
          this.queryPage = queryPage1

        }
        if (this.currenindex == 2) {
          this.table = this.table2;
          this.tableParam.examineStatus = 1
          this.queryPage = queryPage1

        }
        if (this.currenindex == 3) {
          this.table = this.table3;
          this.queryPage = queryPage3
          this.gettableData()
        }
        this.pagesLoading = false
        //此处为执行的函数或者方法
      },
      deep: false,
      immediate: true,
    },
    /**时间选择*/
    datePicker() {
      if (this.datePicker) {
        this.tableParam.startTime = this.datePicker[0]
        this.tableParam.endTime = this.datePicker[1]
      } else {
        this.tableParam.startTime = ''
        this.tableParam.endTime = ''
      }
    },
    /**table1默认全选*/
    tableData() {
      if (this.tableData.length !== 0 && this.currenindex == 1) {
        this.$refs.table.toggleAllSelection()
        // this.generate.startTime = this.tableParam.startTime
        // this.generate.endTime = this.tableParam.endTime
      }
    },
  },
  methods: {

    init() {
      this.tableData = []
      this.datePicker = []
      this.tableParam = this.$options.data().tableParam
      this.gettableData()
    },
    /**添加特殊运载*/
    additem() {
      this.billDetails.concreteSpecialDetails.push(
        {
          concreteCode: this.billDetails.concreteStatement.statementNo,
          materielName: '',
          transportNum: 0,
          distanceInterval: '',
          unitPrice: 0,
          settleAmount: 0
        }
      )
    },
    delitem(index) {
      this.billDetails.concreteSpecialDetails.splice(index, 1)
    },
    /**结算信息合计方量*/
    combined(arr) {
      let num = 0
      arr.forEach(res => {
        num = Number(res.faceValue) + num
      })
      return num.toFixed(2)
    },
    /**结算信息合计金额*/
    combined1(arr) {
      let num = 0
      arr.forEach(res => {
        num = Number(res.settleAmount) + num
      })
      return num
    },
    /**导航栏切换*/
    choose(pages) {
      this.currenindex = pages;
    },
    /**获取对应的搜搜添加*/
    getsearchData() {
      let _this = this
      this.productionSiteId = []
      this.datePicker = []
      this.tableParam = this.$options.data().tableParam
      if (_this.currenindex == 1) {
        QueryPage().then(res => {
          console.log(res)
          this.searchData = res.data
        })
      }
      if (_this.currenindex == 2) {
        QueryPage().then(res => {
          this.searchData = res.data
        })
      }
      if (_this.currenindex == 3) {
        QueryPage().then(res => {
          this.searchData = res.data
        })
      }
    },
    /**合同列表选中*/
    setradio(data) {
      this.searchradio = JSON.stringify(data)
    },
    // setstationsList(a) {
    //   let index = this.searchData.find(res => (res.id == a))
    //   this.stationsList = JSON.parse(index.stations)
    //   this.productionSiteId = []

    // },
    /**确定选择运输合同*/
    submitsearch() {
      this.tableParam.supplierId = JSON.parse(this.searchradio).supplierId
      // this.stationsList = JSON.parse(JSON.parse(this.searchradio).stations)
      this.searchText = JSON.parse(this.searchradio).contractNumber + '-' + JSON.parse(this.searchradio).supplierName
      this.productionSiteId = []
      this.search = false
    },

    /**查询 */
    pagesgettableData() {
      let _this = this
      if (_this.currenindex == 1 || _this.currenindex == 2) {
        if (!_this.tableParam.supplierId) {
          this.$message({
            message: '警告哦，请先选择供应商',
            type: 'warning'
          });
          return
        }
        if (_this.productionSiteId.length == 0) {
          this.$message({
            message: '警告哦，请先选择站点',
            type: 'warning'
          });
          return
        }
        if (_this.datePicker.length == 0) {
          this.$message({
            message: '警告哦，请先选择时间段',
            type: 'warning'
          });
          return
        }
        _this.tableParam.productionSiteId = _this.productionSiteId

        // this.tableParam.productionSiteId = 1
        // this.tableParam.supplierId = 'e7904463ded6441c86478e2fd8e6b3d4'
      }
      this.gettableData()
    },
    /**表格选中数据*/
    tableChange(val) {
      console.log(val)
      this.generate.logisticsList = val
    },
    /**生成结算单*/
    async statements() {
      await generate_statement_detail(this.generate.logisticsList).then(res => {
        this.billDetails = res.data
        this.billDetails.concreteSpecialDetails = []
        console.log(res.data)
      })
      // await getDetail().then(res => {
      //   console.log(res.data)
      // })
      this.billDeta = true

    },
    /**提交结算单*/
    async  combinedSubmit(type) {
      let _this = this
      if (type == 3) {
        _this.$router.push({ name: "sign_Wise_rentunit2", query: { id: _this.low.statementNo, type: 1 } });
        return
      }
      _this.billDetails.type = 1
      _this.billDetails.concreteStatement.statementAmount = _this.combined1(_this.billDetails.concreteSpecialDetails) + _this.combined1(_this.billDetails.concreteDetails)
      await html2canvas(_this.$refs.html).then((res) => {
        let url = res.toDataURL('image/png');
        console.log(url)
        _this.billDetails.img = url
      })
      save_statement_detail(_this.billDetails).then(res => {
        if (res.code == 1001) {
          _this.billDeta = false
          if (type == 2) {
            _this.$router.push({ name: "sign_Wise_rentunit2", query: { id: res.data.statementNo, type: 1 } });
            return
          }
          _this.gettableData()
        }
      })
      console.log(type)
    },
    /**结算单发给供应商*/
    // send(low) {
    //   this.low = low
    //   this.userarr = []
    //   this.useroptons = []
    //   queryUserByID({ id: low.contractId }).then(res => {
    //     this.useroptons = JSON.parse(res.data)
    //     this.userDeta = true
    //   })
    // },
    async userSubmit(low) {
      this.$confirm('确认发送?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        cancelButtonClass: 'bottom_all_two',
        confirmButtonClass: 'bottom_all',
        type: 'warning'
      }).then(async () => {
        let json = {
          contractId: low.contractId,
          type: 5,
          settlementId: low.id,
          settlementNo: low.statementNo,
          times: low.startTime + '-' + low.endTime,
          money: low.statementAmount,
          applyForTime: low.submitTime,
          imgUrl: low.picture,
        }
        // let arr = this.userarr.map(res => (new useritem(res)))
        await informClient(json).then(res => {
          if (res.code == 1001) {
            generate_statement({ statementNo: low.statementNo, supplierConfirm: 1, auditStatus: 1, }).then(() => { })
            this.$message({
              message: '发送成功',
              type: 'success'
            });
            this.gettableData()
            this.userDeta = false
          }
        })
      })
    },
    show(low) {
      this.low = low
      get_statement_detail_by_statement_no({ statementNo: low.statementNo }).then(res => {
        if (res.code == 1001) {
          this.billList1 = res.data
          this.billDeta1 = true
        }
      })
    },


  },
};
</script>

<style lang="scss" scoped>
.dialoginfo {
  padding: 20px 20px 0 20px;
  max-height: 400px;
  overflow: auto;
}
.tabtop {
  width: 571px;
}
.el-input,
.el-select {
  width: 240px;
}
/*
 <el-link class="table_link" :underline="false">查看配合比</el-link>*/
.table_link {
  margin: 0 10px;
  color: $bg_color;
  cursor: pointer;
}

.table_link:hover {
  opacity: 0.8;
}
.bill_top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  .text {
    font-weight: 600;
    color: #000;
  }
}
.bill_title {
  font-size: 18px;
  font-weight: 600;
  padding: 15px 0;
}
.bill_title1 {
  font-size: 18px;
  font-weight: 600;
  padding: 20px 0;
}
.bill_subtitle {
  padding: 20px 0;
  > span {
    padding-right: 20px;
  }
  .text {
    color: #000;
  }
}
.combined {
  border: 1px solid #ebeef5;
  text-align: center;
  line-height: 40px;
}
</style>
